// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Inference;

/// <summary>
/// <para>
/// Configuration options when storing the inference endpoint
/// </para>
/// </summary>
public sealed partial class InferenceEndpoint
{
	/// <summary>
	/// <para>
	/// The service type
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("service")]
	public string Service { get; set; }

	/// <summary>
	/// <para>
	/// Settings specific to the service
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("service_settings")]
	public object ServiceSettings { get; set; }

	/// <summary>
	/// <para>
	/// Task settings specific to the service and task type
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("task_settings")]
	public object? TaskSettings { get; set; }
}

/// <summary>
/// <para>
/// Configuration options when storing the inference endpoint
/// </para>
/// </summary>
public sealed partial class InferenceEndpointDescriptor : SerializableDescriptor<InferenceEndpointDescriptor>
{
	internal InferenceEndpointDescriptor(Action<InferenceEndpointDescriptor> configure) => configure.Invoke(this);

	public InferenceEndpointDescriptor() : base()
	{
	}

	private string ServiceValue { get; set; }
	private object ServiceSettingsValue { get; set; }
	private object? TaskSettingsValue { get; set; }

	/// <summary>
	/// <para>
	/// The service type
	/// </para>
	/// </summary>
	public InferenceEndpointDescriptor Service(string service)
	{
		ServiceValue = service;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Settings specific to the service
	/// </para>
	/// </summary>
	public InferenceEndpointDescriptor ServiceSettings(object serviceSettings)
	{
		ServiceSettingsValue = serviceSettings;
		return Self;
	}

	/// <summary>
	/// <para>
	/// Task settings specific to the service and task type
	/// </para>
	/// </summary>
	public InferenceEndpointDescriptor TaskSettings(object? taskSettings)
	{
		TaskSettingsValue = taskSettings;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		writer.WritePropertyName("service");
		writer.WriteStringValue(ServiceValue);
		writer.WritePropertyName("service_settings");
		JsonSerializer.Serialize(writer, ServiceSettingsValue, options);
		if (TaskSettingsValue is not null)
		{
			writer.WritePropertyName("task_settings");
			JsonSerializer.Serialize(writer, TaskSettingsValue, options);
		}

		writer.WriteEndObject();
	}
}